package com.wanshi.entity;


import com.wanshi.utils.StringUtils;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
public class Cust {

    /*
    username gender birthday phonenum email hobby TYPE introduce
     */

    private Integer id;
    private String username;
    private String gender;
    private String birthday;
    private String phonenum;
    private String email;
    private String hobby;
    private String type;
    private String introduce;


    public Map<String,String> checkUser(){
        Map<String,String> errorMap = new HashMap<>();
        String zhengze = "^[a-zA-Z0-9_]{6,20}$";
        String youxiang = "^[A-Za-z0-9\\u4e00-\\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
        String phone = "/^1(3\\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$/";
        if(StringUtils.isEmpty(username)){
            errorMap.put("username","用户名不能为空");
        }else if(!username.matches(zhengze)){
            errorMap.put("username","用户名不满足格式");
        }

        if(StringUtils.isEmpty(gender)){
            errorMap.put("gender","性别不能为空");
        }

        if(StringUtils.isEmpty(phonenum)){
            errorMap.put("phonenum","手机号不能为空");
        }
        if(StringUtils.isEmpty(email)){
            errorMap.put("email","邮箱不能为空");
        }else if (!email.matches(youxiang)){
            errorMap.put("email","邮箱不满足格式");
        }
        if(StringUtils.isEmpty(hobby)){
            errorMap.put("hobby","爱好不能为空");
        }
        if(StringUtils.isEmpty(type)){
            errorMap.put("type","类型不能为空");
        }
        if(StringUtils.isEmpty(introduce)){
            errorMap.put("introduce","请填写自我介绍");
        }

        return errorMap;
    }

}
